<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //构造方法： 属性值不相同的  原型：属性值相同的往原型里面放


        //构造方法： 属性值不相同的
        //构造方法里面的属性称为私有属性
        function Rect(length, width) {
            this.length = length;
            this.width = width;

        }

        //原型：属性值相同的往原型里面放
        //原型里面的属性称为公有属性
        Rect.prototype.l = function() {
            return 2 * (this.length + this.width);
        }

        Rect.prototype.s = function() {
            return this.length * this.width;
        }

        var p = new Rect(10, 30);
        console.log(p);


        function Triggle(length, height) {
            this.length = length;
            this.height = height;
        }

        Triggle.prototype.s = function() {
            return this.length + this.height / 2;
        }

        Triggle.prototype.l = function() {
            return 3 * this.length;
        }

        var t = new Triggle(10, 20);
        console.log(t);
    </script>
</body>

</html>